/* 
** (Copyright) sejishikong <sejishikong@263.net>
** Authors:    sejishikong <sejishikong@263.net>
**             Wei Lian <lianwei2003.student@sina.com> 
** Maintainer: Wei Lian
**    This program is free software; you can redistribute it and/or modify
**    it under the terms of the GNU General Public License Version 2 as
**    published by the Free Software Foundation;
**
**    This program is distributed in the hope that it will be useful,
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**    GNU General Public License for more details.
**
**    You should have received a copy of the GNU General Public License
**    along with this program; if not, write to the Free Software
**    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
*/

#ifndef MYLISTITEM_H
#define MYLISTITEM_H

#include <qlistview.h>

class MyListItem:public QListViewItem {
  public:
    MyListItem(QListView * parent):QListViewItem(parent) {
	bcolor = Qt::white;
	fcolor = Qt::black;
	state = 0;
    }
    MyListItem(QListViewItem * parent):QListViewItem(parent) {
	bcolor = Qt::white;
	fcolor = Qt::black;
	state = 0;
    }
  MyListItem(QListView * parent, QListViewItem * after):QListViewItem(parent, after)
    {
	bcolor = Qt::white;
	fcolor = Qt::black;
	state = 0;
    }
  MyListItem(QListViewItem * parent, QListViewItem * after):QListViewItem(parent, after)
    {
	bcolor = Qt::white;
	fcolor = Qt::black;
	state = 0;
    }

    QColor fcolor;
    QColor bcolor;
    int state;

  private:

    void paintCell(QPainter * p, const QColorGroup & cg,
		   int column, int width, int alignment) {
	QColorGroup _cg(cg);
//    QColor c = _cg.text ();
	_cg.setColor(QColorGroup::Base, bcolor);
	_cg.setColor(QColorGroup::Text, fcolor);

	QListViewItem::paintCell(p, _cg, column, width, alignment);
//    _cg.setColor (QColorGroup::Text, c);
    }

    int compare(int that, int other) const {
	if (that < other)
	    return -1;
	else if (that > other)
	    return 1;
	return 0;
    }
    int compare(QListViewItem * i, int col, bool ascending) const {
	switch (col) {
	case 1:
	case 3:
	case 4:
	case 5:
	case 6:
	case 7:
	    return compare(text(col).toInt(), i->text(col).toInt());
	    default:return QListViewItem::compare(i, col, ascending);
	}
    }
};


#endif
